package ext.generic.doc.processors;

import ext.generic.doc.DocWorkflowUtil;

import java.io.Serializable;
import java.util.Vector;
import wt.workflow.work.WorkItem;
import wt.method.RemoteAccess;
import wt.util.WTException;
import wt.workflow.work.WfAssignedActivity;
import wt.fc.QueryResult;
import wt.fc.ObjectVector;
import wt.doc.WTDocument;
import wt.doc.WTDocumentMaster;

import wt.fc.collections.WTArrayList;


public class DocWorkFlowProcessor implements RemoteAccess, Serializable{

    public DocWorkFlowProcessor() {
    }
    
    public static WTArrayList getReviewDoc(WorkItem wi) throws WTException, Exception
    {
        WfAssignedActivity wfassignedactivity = (WfAssignedActivity)wi.getSource().getObject();
        WTArrayList reviewDoc=new WTArrayList();
        reviewDoc=(WTArrayList)(wfassignedactivity.getContext().getValue("reviewObjs"));
        for(int i=0;i<reviewDoc.size();i++)
        {
                WTDocument doc=(WTDocument)reviewDoc.getPersistable(i);
                WTDocumentMaster master=(WTDocumentMaster)doc.getMaster();
                if(!doc.isLatestIteration())
                {
                        reviewDoc.set(i,DocWorkflowUtil.getLatestWTDocument(master));
                }
        }
    	//ObjectVector objvec=new ObjectVector(reviewDoc);
    	//QueryResult qr=new QueryResult(objvec);
    	//return qr;
    	return reviewDoc;
    }
}
